package com.example.demo.controller;

import com.example.demo.bean.Department;
import com.example.demo.sevice.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class DepartmentController {
    @Autowired
    private DepartmentService departmentService;

    /*查询*/
    @RequestMapping("department")
    public List<Department> department() {
        return departmentService.department();
    }

    /*新增*/
    @RequestMapping("department1")
    public void insert(@RequestParam("department1") String department) {
        System.out.println(department);
        departmentService.insert(department);
    }

    /*删除*/
    @RequestMapping("department2")
    public void delete(@RequestParam("department1") String department) {
        departmentService.delete(department);
    }

    /*修改*/
    @RequestMapping("department3")
    public void update(Department department) {
        departmentService.update(department);
        System.out.println(department);
    }
}
